<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="p1"></p>
<script>
/*for(var i = 0; i < 1000; i++){
 document.write(i + "&nbsp;");
 if((i + 1) % 10 == 0){
 document.write("<br>")
 }
 }*/
var p1 = document.getElementById("p1");
var msg = "";

for (var year = 1700, count = 0; year < 2030; year++){
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
        msg += year + "&nbsp;"
        count++;
        if (count > 0 && count % 6 == 0){
            msg += "<br>"
        }
    }
}
p1.innerHTML = msg;
</script>
</body>
</html>